﻿@{
    ViewBag.Title = "Creat";
}
@model KingRoad.EPM.ProjectInfoEntity.PROJECT_INSTRUCTIONS
<link href="/Scripts/uploadify/uploadify.css" rel="stylesheet" type="text/css" />
<script src="/Scripts/uploadify/swfobject.js" type="text/javascript"></script>
<script src="/Scripts/uploadify/jquery.uploadify.v2.1.4.min.js" type="text/javascript"></script>
<script src="/Scripts/jQuery/jquery.validate.min.js" type="text/javascript"></script>
<script src="/Scripts/jQuery/jquery.validate.unobtrusive.min.js" type="text/javascript"></script>
<script type="text/javascript">
    var UpIndex = 0; //判断是否为编辑
    //绑定上传的方法
    function Common_Instructions_Create_BindFileUpload() {
        $('#Common_Instructions_Create_Form_FileLoad').uploadify({
            'uploader': '/Scripts/uploadify/uploadify.swf?id=' + (new Date()).getTime(),
            'script': '/Permission/Instructions/UploadFile',
            'cancelImg': '/Scripts/uploadify/cancel.png',
            'folder': '@ViewBag.filePath',
            'queueID': 'Common_Reportlib_Create_Form_FileQueue',
            'wmode': 'transparent',
            'fileDesc': '请选择' + '@ViewBag.filetype' + '文件',
            'fileExt': '@ViewBag.filetype',
            'sizeLimit': '@ViewBag.fileSize',
            'buttonImg': '/Scripts/uploadify/button.gif',
            'height': 30,
            'buttonText': "选择文件",
            'multi': false,
            'onComplete': function (event, queueID, fileObj, response, data) {
                if (response == "1") {
                    alertMsg.warn("上传文件类型不正确!");
                }
                else if (response == "2") {
                    alertMsg.warn("上传文件大小超过限制!");
                }
                else if (response == "3") {
                    alertMsg.warn("出现异常上传失败，请稍后再试!");
                }
                else {
                    $("#Instructions_Path").val(response);
                    //if (UpIndex == 0) {
                    //$("#Instructions_Create_Form").submit(); //表单提交
                    //}
                }
            },
            'onError': function (event, queueID, fileObj, errorObj) {
                alertMsg.warn(errorObj.type + "Error:" + errorObj.info);
            }
        });
    }
//    function OnSubmit(id) {
//        if (id == 1) {
//            UpIndex = 0;
//            $('#Common_Instructions_Create_Form_FileLoad').uploadifyUpload();
//        }
//        else {
//            $("#Instructions_Create_Form").submit();
//        }
//    }
    function UPLoadFile() {
        $('#Common_Instructions_Create_Form_FileLoad').uploadifyUpload();
    }
    //页面加载事件
    $(document).ready(function () {
        $("#Instructions_MoudleID").val(MoudleID);
        $("#Instructions_Create_Form").submit(function () {
            return false;
        });
        Common_Instructions_Create_BindFileUpload();
    });
</script>
<div class="pageContentD">
    @{Html.EnableClientValidation();}
    @using (Html.BeginForm("Creating", "Instructions", null, FormMethod.Post, new { onsubmit = "return validateCallback(this,Instructions_Create_Callback);", @id = "Instructions_Create_Form", @class = "pageForm" }))
    {   
        <div class="pageFormContent" layouth="60">
            <table width="95%" class="tab01">
                <tr>
                    <td class="td1">
                        <label>
                            排序ID：</label>
                    </td>
                    <td>
                        @Html.TextBoxFor(m => m.Instructions_SortCode)
                        @Html.HiddenFor(m => m.Instructions_Path)
                        @Html.HiddenFor(m => m.Instructions_MoudleID)
                        @Html.Raw(Model == null || Model.Instructions_ID == null ? "" : "<input type=\"hidden\" value=\"" + Model.Instructions_ID + "\" id=\"Instructions_ID\" name=\"Instructions_ID\" />")
                        @Html.ValidationMessageFor(m => m.Instructions_SortCode)
                    </td>
                </tr>
                <tr>
                    <td class="td1">
                        <label>
                            说 明：</label>
                    </td>
                    <td>
                        @Html.TextBoxFor(m => m.Instructions_Details)
                        @Html.ValidationMessageFor(m => m.Instructions_Details)
                    </td>
                </tr>
                <tr>
                    <td class="td1">
                        <label>
                            选择图片：</label>
                    </td>
                    <td style="height: 40px; width: 70%;">
                        <input type="file" name="Common_Instructions_Create_Form_FileLoad" id="Common_Instructions_Create_Form_FileLoad" />
                         <span onclick="UPLoadFile()">上传</span>
                    </td>
                    @*@if (Model != null)
                    {*@
                        
                   @* }*@
                </tr>
                <tr>
                    <td>
                    </td>
                    <td height="60" align="center">
                        <div id="Common_Reportlib_Create_Form_FileQueue" style="width: 100px">
                        </div>
                    </td>
                </tr>
            </table>
        </div>
        <div class='formBar'>
            <ul>
                <li>@*@if (Model == null || Model.Instructions_ID == null)
                    { *@
                    <button type="submit" class="btn btn-success btn-sm" id="InInstructionsCreate1" @*onclick="OnSubmit(1)"*@>
                        保存</button>
                    @* }
                    else
                    { 
                        <button type="submit" class="btn btn-success btn-sm" id="InInstructionsCreate2" @*onclick="OnSubmit(2)">
                            保存</button>
                    }*@ </li>
                <li>
                    <button type="button" class="close btn btn-default btn-sm">
                        取消</button>
                </li>
            </ul>
        </div>
    }
</div>
